/*
 * @Author: qin
 * @Date:   2018-08-28
 * +----------------------------------------------------------------------
 * | admin [ 后台管理系统公共配置信息 ]
 * | 角色底层模块
 * +----------------------------------------------------------------------
 */
layui.define(['jquery', 'configure', 'configureCom', 'sessionFun'], function (exports) {
    var $ = layui.jquery;
    var configure = layui.configure;
    var configureCom = layui.configureCom;
    var sessionFun = layui.sessionFun;
    //获取对应导航菜单中的 的数量
    var navNum = function (code, numList) {
        var isHave = '-1';
        $.each(numList, function (i, v) {
            if (v.menuCode === code) {
                isHave = v.count;
                return;
            }
        });
        return isHave;
    };
    var nav = {
        //获取角色信息
        getInfo: function () {
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(configure.ROLE_INFO_HTTP).then(function (res) {

                });
            });
        },
        //获取角色菜单，同时将角色保存如session
        get: function () {
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(configure.NAV_HTTP).then(function (res) {
                    resolve(res);
                }, function (res) {
                    reject(res);
                });
            });
        },
        getCount: function () {
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(configure.NAV_NUM_HTTP).then(function (res) {
                    resolve(res.result);
                });
            });
        }
    };
    exports('nav', nav);
});